// 代表 GitHub 仓库的所有者
class RepoOwner {
  final String login;
  final String avatarUrl;

  RepoOwner({required this.login, required this.avatarUrl});

  factory RepoOwner.fromJson(Map<String, dynamic> json) {
    return RepoOwner(
      login: json['login'] ?? 'Unknown',
      avatarUrl: json['avatar_url'] ?? '',
    );
  }
}

// 代表一个 GitHub 仓库
class Repo {
  final int id;
  final String name;
  final String fullName;
  final RepoOwner owner;
  final String? description;
  final int stargazersCount;
  final String htmlUrl;

  Repo({
    required this.id,
    required this.name,
    required this.fullName,
    required this.owner,
    this.description,
    required this.stargazersCount,
    required this.htmlUrl,
  });

  factory Repo.fromJson(Map<String, dynamic> json) {
    return Repo(
      id: json['id'],
      name: json['name'] ?? 'No Name',
      fullName: json['full_name'] ?? '',
      owner: RepoOwner.fromJson(json['owner'] ?? {}),
      description: json['description'],
      stargazersCount: json['stargazers_count'] ?? 0,
      htmlUrl: json['html_url'] ?? '',
    );
  }
}
